﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReExamSubjectDAL : SyncBase<Model.ReExamSubject>
    {
        static ReExamSubjectDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReExamSubjectDAL.addSQL = @"insert into TempReExamSubject(
ExamID,LessionID,TeacherID,QtypeCode,QtypeName,QuestionID,ComID,Number)
 values (
@ExamID,@LessionID,@TeacherID,@QtypeCode,@QtypeName,@QuestionID,@ComID,@Number)";
            ReExamSubjectDAL.tbName = "TempReExamSubject";
            ReExamSubjectDAL.remoteUrl = "/Ayyfford/AddReExamSubject";
            ReExamSubjectDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6},{7}),",
                                          t.ExamID.NullNumber(), t.LessionID.NullNumber(), t.TeacherID.NullNumber(), t.QtypeCode.NullString(), t.QtypeName.NullString(), t.QuestionID.NullNumber(), t.ComID.NullNumber(), t.Number.NullNumber());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReExamSubject t)
        {
            SyncBase<Model.ReExamSubject>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReExamSubject>.AsyncData();
        }
    }
}
